from warnings import filterwarnings

import MySQLdb
from DBUtils.PersistentDB import PersistentDB


class Pool:

    def __init__(self, **kargs):
        filterwarnings('error', category=MySQLdb.Warning)
        POOL_ARGS = {
            'creator': MySQLdb,
            'user': 'root',
            'passwd': '123321',
            'port': 3306,
            'charset': 'utf8mb4',
            'host': '172.17.0.1',
            'db': 'Bi6IPlGDh'
        }
        POOL_ARGS.update(kargs)
        self.pool = PersistentDB(**POOL_ARGS)

    def __getattr__(self, name):
        if name in self.__dict__:
            return self.__dict__[name]

        return getattr(self.pool, name)
